package bitetorrentserver;

import java.util.Hashtable;
import java.util.Iterator;
import java.util.Set;

/**
 *
 * @author user
 */
public class Request {

    public Hashtable<String, String> parameter;

    public Request(String query) {
        parameter = new Hashtable<String, String>();
        if (query != null) {
            String par[] = query.split("&");

            for (int i = 0; i < par.length; ++i) {
                String temp[] = par[i].split("=");
                if (temp.length == 2) {
                    parameter.put(temp[0], temp[1]);
                }
            }
        }
    }

    @Override
    public String toString() {
        Set<String> set = parameter.keySet();
        Iterator<String> iter = set.iterator();
        String str;
        String result = "";

        while (iter.hasNext()) {
            str = iter.next();
            result += str + " : " + parameter.get(str) + "\n";
        }

        return result;
    }
}
